<template>
    <div>
        <van-cell-group>
            <van-nav-bar title="修改个人信息" left-text="返回" left-arrow @click-left="$router.back()">
                <van-button type="info" slot="right" size="small" @click="submitForm">提交</van-button>
            </van-nav-bar>
            <van-field v-model="userInfo.userCode" clearable label="用户名" placeholder="用户名不可修改" disabled/>
            <van-field v-model="userInfo.nickName" clearable label="昵称" placeholder="请输入昵称"/>
<!--            <van-field v-model="userInfo.sex" clearable label="性别" placeholder="请输入性别"/>-->
            <van-field v-model="userInfo.address" clearable label="地区" placeholder="请输入地区"/>
            <van-field v-model="userInfo.phone" clearable label="手机号码" placeholder="请输入手机号码"/>
            <van-field v-model="userInfo.email" clearable label="邮箱地址" placeholder="请输入邮箱地址"/>
            <!--        -->
            <!--        <label class="label">用户名</label>-->
            <!--        <input type="text" class="txt_input" v-model="userCode" />-->
            <!--        <br>-->
            <!--        <label class="label">显示昵称</label>-->
            <!--        <input type="text" class="txt_input" v-model="nickName"/>-->
            <!--        <br>-->
            <!--        <label class="label">性别</label>-->
            <!--        <br>-->
            <!--        <div class="radio_box">-->
            <!--            <input type="radio" class="radio" v-model="sex" value="1"/>男-->
            <!--            <input type="radio" class="radio" v-model="sex" value="0"/>女-->
            <!--        </div>-->
            <!--        <br>-->
            <!--        <br>-->
            <!--        <label class="label">地区</label>-->
            <!--        <input type="text" class="txt_input" v-model="address"/>-->
            <!--        <br>-->
            <!--        <label class="label">手机号码</label>-->
            <!--        <input type="text" class="txt_input" v-model="phone"/>-->
            <!--        <br>-->
            <!--        <label class="label">邮箱地址</label>-->
            <!--        <input type="text" class="txt_input" v-model="email"/>-->
        </van-cell-group>

        <van-radio-group v-model="userInfo.sex" >
            <van-cell-group title="性别">
                <van-cell title="男" clickable @click="userInfo.sex = 1">
                    <van-radio name=1 />
                </van-cell>
                <van-cell title="女" clickable @click="userInfo.sex = 0">
                    <van-radio name=0 />
                </van-cell>
            </van-cell-group>
        </van-radio-group>
    </div>
</template>

<script>
    import ltxService from '../services/LtxService'
    import {Toast} from "vant";

    export default {
        mounted(){
            this.getUserInfo()
        },
        name: "UpdateUserInfo",
        methods:{
            getUserInfo()
            {
                ltxService.getUserInfo().then(resp=>{
                    this.userInfo=resp.data.data
                })
            },
            submitForm()
            {

                ltxService.updateUserInfo(this.userInfo).then(resp=>{
                        Toast.success({
                            duration: 500,       // 持续展示 toast
                            message: '更新成功'
                        })
                }
                )
            }
        },
        data() {
            return {
                userInfo:{
                userCode: "CDX",
                nickName: "CaiDingxian",
                password: "123456", password2: "123456",
                sex: 1,
                address: "1100",
                phone: "15625538787",
                email: "1617071974@qq.com",
                msg: "请填写用户信息"
                }
            }
        },
    }
</script>

<style scoped>

</style>